$('.easyui-dialog').dialog({
	collapsible: false,
	minimizable: false,
	maximizable: false,
	closable: true
});
$("#loginBtn").click(function(){
	var usercode = $("#usercode").val();
	var password = $("#password").val();
	console.log('login btn click',usercode,password);
	$.ajax({
		type: 'POST',
		url: './api/login',
		dataType:'json',
		data: {usercode:usercode,password:password},
		success: function(data){
			if(data.code===0){
				window.location.href="main.html";
			}
			console.log(data);
			console.log("login return:",data.data);
			//$.messager.tips(data.msg);
			$.prompt(data.msg);
		}
	});
});
$(document).ajaxError(function(XMLHttpRequest, textStatus, errorThrown){
	//console.log(textStatus);
	$.messager.confirm('系统提示','login api错误:'+textStatus.statusText,function(r){
		if(r){
			window.close();
		}else{
			console.log(textStatus);
		}
	});
});
$(function(){
	$("#usercode").textbox('textbox').bind('keydown',function(e){
		console.log("用户代码回车",e.keyCode);
		 if (e.keyCode == 13){
			 $("#password").textbox('textbox').focus();
		 }
	});
	$("#password").textbox('textbox').bind('keydown',function(e){
		console.log("用户密码回车",e.keyCode);
		 if (e.keyCode == 13){
			 $("#loginBtn").trigger('click');
		 }
	})
});